import { defineStore } from 'pinia';
import { ref } from 'vue';

export const useAgentStore = defineStore('agentConfig', () => {
  const agents = ref<Array<{ baseUrl: string; token: string }>>([]);

  const setAgents = (newAgents: Array<{ baseUrl: string; token: string }>) => {
    agents.value = newAgents;
    localStorage.setItem('agentConfig', JSON.stringify(newAgents));
  };

  const loadAgents = () => {
    const storedAgents = localStorage.getItem('agentConfig');
    if (storedAgents) {
      agents.value = JSON.parse(storedAgents);
    }
  };

  return {
    agents,
    setAgents,
    loadAgents,
  };
});